home *** CD-ROM | disk | FTP | other *** search
/ mail.altrad.com / 2015.02.mail.altrad.com.tar / mail.altrad.com / TEST / office deutch / ADMIN / KO-KR / OCT.CHM / html / expcollapse.js < prev    next >
Text File  |  2012-07-31  |  11KB  |  390 lines

  1. //Generic Display code
  2. //Updated 11/9/00 - updated outline3()
  3.  
  4. var L_COLLAPSE_TEXT="Hide All";
  5. var L_EXPAND_TEXT="Show All";
  6.  
  7. function ExpandAll()
  8. {
  9.     // Expand all 
  10.     var iSpan
  11.     var iSpanSource
  12.     var oSpan
  13.     var sCaption
  14.     var sAction
  15.     var sImage
  16.     
  17.     // Determine the action, and the picture to replace
  18.     sCaption=document.all("ExpandAll").innerHTML;
  19.     if (sCaption==L_EXPAND_TEXT)
  20.         {
  21.         sAction="expanded";
  22.         sImage="bluedrop.gif"
  23.         document.all("picHeader").src="collapsetri.gif";
  24.         document.all("ExpandAll").innerHTML=L_COLLAPSE_TEXT;
  25.         }
  26.     else
  27.         {
  28.         sAction="collapsed";
  29.         sImage="blueup.gif"
  30.         document.all("picHeader").src="expandtri.gif";
  31.         document.all("ExpandAll").innerHTML=L_EXPAND_TEXT;
  32.         }
  33.  
  34.     // Execute the action for all expand SPANs    
  35.     for (iSpan=0; iSpan < document.all.tags("DIV").length; iSpan++)
  36.         {    
  37.             oSpan=document.all.tags("DIV").item(iSpan);
  38.             iSpanSource=oSpan.sourceIndex;
  39.             if (oSpan.id=="ExpCol")
  40.             {
  41.                 document.all.tags("DIV").item(iSpan).className=sAction;
  42.                 if(document.all(iSpanSource-1).tagName=="IMG" && document.all(iSpanSource-2).tagName!="IMG")
  43.                 {
  44.                     document.all(iSpanSource-1).src=sImage;
  45.                 }
  46.                 else if(document.all(iSpanSource-2).tagName=="IMG")
  47.                 {
  48.                     document.all(iSpanSource-2).src=sImage
  49.                 }
  50.                  
  51.             }
  52.             
  53.             // Handle the Q tag added late for Loc
  54.             if (document.all(iSpanSource-1).tagName=="Q")
  55.             {
  56.                 document.all(iSpanSource-2).src=sImage;
  57.             }
  58.             
  59.             
  60.         }
  61.  
  62.  
  63.     // Change the text and the picture of the main caller
  64.     document.all("ExpandAll").className="DropDown";
  65.  
  66.     // Now we do the inline defs
  67.     var cLinks = document.all.tags("A");
  68.     var iNumLinks = cLinks.length;
  69.  
  70.       for (var i=0;i<iNumLinks;i++)
  71.       {
  72.         cLink=document.all.tags("A").item(i);
  73.         
  74.         switch (sAction)
  75.         {
  76.             case 'expanded':
  77.                 if (cLink.className=="glossary" && cLink.getAttribute("State")!="On")
  78.                 {
  79.                     cLinks[i].click();
  80.                 }
  81.                 else if (cLink.className=="HidePopUp")
  82.                 {
  83.                     cLinks[i].click();
  84.                 }
  85.                 
  86.                 break;
  87.             case 'collapsed':
  88.                 if (cLink.className=="glossary" && cLink.getAttribute("State")=="On")
  89.                 {
  90.                     cLinks[i].click();
  91.                 }
  92.                 else if (cLink.className=="HidePopUp")
  93.                 {
  94.                     cLinks[i].click();
  95.                 }
  96.                 break;
  97.         }
  98.       }
  99.  
  100.  
  101.     
  102.     
  103. }
  104.  
  105. function Outline2()
  106. {
  107.  
  108.     window.event.returnValue=0    
  109.  
  110.     //Expand or collapse if a list item is clicked.
  111.     var open = event.srcElement;
  112.  
  113.     //Verify that the tag which was clicked was either the 
  114.     //trigger tag or nested within a trigger tag.
  115.     var el = checkParent(open,"A");
  116.     if(null != el)
  117.     {    
  118.         var incr=0;
  119.         var elmPos = 0;
  120.         var parentSpan;
  121.         var fBreak
  122.  
  123.         //Get the position of the element which was clicked
  124.         elemPos = window.event.srcElement.sourceIndex;
  125.  
  126.         //Search for a SPAN tag
  127.         for (parentSpan = window.event.srcElement.parentElement;
  128.             parentSpan!=null;
  129.             parentSpan = parentSpan.parentElement) 
  130.         {
  131.             //test if already at a span tag 
  132.             if (parentSpan.tagName=="DIV") 
  133.             {
  134.                 //alert("Parent Element is a SPAN");
  135.                 incr=1;
  136.                 break;
  137.             }
  138.             
  139.             //Test if the tag clicked was in a body tag or in any of the possible kinds of lists
  140.             //we perform this test because nested lists require special handling
  141.             if (parentSpan.tagName=="BODY" || parentSpan.tagName=="UL" || parentSpan.tagName=="OL"|| parentSpan.tagName=="P") 
  142.             {
  143.                 //Determine where the span to be expanded is.  
  144.                 for (incr=1; (elemPos+incr) < document.all.length; incr++)
  145.                 {    
  146.                     //verify we are at an expandable Div tag
  147.                     if(document.all(elemPos+incr).tagName=="DIV" && 
  148.                     (document.all(elemPos+incr).className=="expanded" ||
  149.                      document.all(elemPos+incr).className=="collapsed"))
  150.                     {
  151.                         fBreak=1;
  152.                         break;
  153.                     }
  154.                     //If the next tag following the list item (li) is another 
  155.                     //list item(li) return in order to prevent accidentally opening
  156.                     //the next span in the list
  157.                     else if(document.all(elemPos+incr).tagName=="LI")
  158.                     {
  159.                         return;
  160.                     }
  161.                 }
  162.             }
  163.             //determine if we need to break out of the while loop (kind of a kludge since theres no goto in javascript)
  164.             if(fBreak==1)
  165.             {
  166.                 break;
  167.             }
  168.         }
  169.  
  170.     }
  171.     else
  172.     {
  173.         //Alert("Return!");
  174.         return;
  175.     }
  176.  
  177.     //Now that we've identified the span, expand or collapse it
  178.     if(document.all(elemPos+incr).className=="collapsed")
  179.     {
  180.         
  181.         document.all(elemPos+incr).className="expanded"
  182.         document.all(elemPos+1).src="bluedrop.gif";
  183.         if(open.tagName=="IMG"){open.src="bluedrop.gif";}
  184.         if(open.tagName=="B")
  185.             {
  186.             if(open.parentElement.all.tags("IMG").length != 0)
  187.                 {open.parentElement.all.tags("IMG").item(0).src="bluedrop.gif";}
  188.             }
  189.     }
  190.     else if(document.all(elemPos+incr).className=="expanded")
  191.     {
  192.         document.all(elemPos+incr).className="collapsed"
  193.         document.all(elemPos+1).src="blueup.gif";
  194.         if(open.tagName=="IMG"){open.src="blueup.gif";}
  195.         if(open.tagName=="B")
  196.             {
  197.             if(open.parentElement.all.tags("IMG").length != 0)
  198.                 {open.parentElement.all.tags("IMG").item(0).src="blueup.gif";}
  199.             }
  200.     }
  201.     else
  202.     {
  203.         return;
  204.     }
  205.     event.cancelBubble = true;
  206. //    open.scrollIntoView(true);
  207. }
  208.  
  209. function Outline3()
  210. {
  211.  
  212.     window.event.returnValue=0    
  213.  
  214.     //Expand or collapse if a list item is clicked.
  215.     var open = event.srcElement;
  216.  
  217.     //Verify that the tag which was clicked was either the 
  218.     //trigger tag or nested within a trigger tag.
  219.     var el = checkParent(open,"A");
  220.     if(null != el)
  221.     {    
  222.         var incr=0;
  223.         var elmPos = 0;
  224.         var parentSpan;
  225.         var fBreak
  226.  
  227.         //Get the position of the element which was clicked
  228.         elemPos = window.event.srcElement.sourceIndex;
  229.  
  230.         //Search for a SPAN tag
  231.         for (parentSpan = window.event.srcElement.parentElement;
  232.             parentSpan!=null;
  233.             parentSpan = parentSpan.parentElement) 
  234.         {
  235.             //test if already at a span tag 
  236.             if (parentSpan.tagName=="DIV") 
  237.             {
  238.                 //alert("Parent Element is a SPAN");
  239.                 //incr=1;
  240.                 //break;
  241.             }
  242.             
  243.             //Test if the tag clicked was in a body tag or in any of the possible kinds of lists
  244.             //we perform this test because nested lists require special handling
  245.             if (parentSpan.tagName=="BODY" || parentSpan.tagName=="UL" || parentSpan.tagName=="OL"|| parentSpan.tagName=="P") 
  246.             {
  247.                 //Determine where the span to be expanded is.  
  248.                 for (incr=1; (elemPos+incr) < document.all.length; incr++)
  249.                 {    
  250.                     //verify we are at an expandable Div tag
  251.                     if(document.all(elemPos+incr).tagName=="DIV" && 
  252.                     (document.all(elemPos+incr).className=="expanded" ||
  253.                      document.all(elemPos+incr).className=="collapsed"))
  254.                     {
  255.                         fBreak=1;
  256.                         break;
  257.                     }
  258.                     //If the next tag following the list item (li) is another 
  259.                     //list item(li) return in order to prevent accidentally opening
  260.                     //the next span in the list
  261.                     else if(document.all(elemPos+incr).tagName=="LI")
  262.                     {
  263.                         return;
  264.                     }
  265.                 }
  266.             }
  267.             //determine if we need to break out of the while loop (kind of a kludge since theres no goto in javascript)
  268.             if(fBreak==1)
  269.             {
  270.                 break;
  271.             }
  272.         }
  273.  
  274.     }
  275.     else
  276.     {
  277.         Alert("Return!");
  278.         return;
  279.     }
  280.  
  281.     //Now that we've identified the span, expand or collapse it
  282.     //Now that we've identified the span, expand or collapse it
  283.     if(document.all(elemPos+incr).className=="collapsed")
  284.     {
  285.         
  286.         document.all(elemPos+incr).className="expanded"
  287.         document.all(elemPos+1).src="bluedrop.gif";
  288.         if(open.tagName=="IMG"){open.src="bluedrop.gif";}
  289.         if(open.tagName=="B")
  290.             {
  291.             if(open.parentElement.all.tags("IMG").length != 0)
  292.                 {open.parentElement.all.tags("IMG").item(0).src="bluedrop.gif";}
  293.             }
  294.     }
  295.     else if(document.all(elemPos+incr).className=="expanded")
  296.     {
  297.         document.all(elemPos+incr).className="collapsed"
  298.         document.all(elemPos+1).src="blueup.gif";
  299.         if(open.tagName=="IMG"){open.src="blueup.gif";}
  300.         if(open.tagName=="B")
  301.             {
  302.             if(open.parentElement.all.tags("IMG").length != 0)
  303.                 {open.parentElement.all.tags("IMG").item(0).src="blueup.gif";}
  304.             }
  305.     }
  306.     else
  307.     {
  308.         return;
  309.     }
  310.     event.cancelBubble = true;
  311. //    open.scrollIntoView(true);
  312. }
  313.  
  314. function checkParent(src,dest)
  315. {
  316.     //Search for a specific parent of the current element.
  317.     while(src !=null)
  318.     {
  319.         if(src.tagName == dest)
  320.         {
  321.             return src;
  322.         }
  323.         src = src.parentElement;
  324.     }
  325.     return null;
  326. }
  327.  
  328. //This function displays content from different source HTML files
  329. function showPopup(filename, theSpan){
  330.  
  331.  
  332.     //Get the position of the element which was clicked
  333.     elemPos = window.event.srcElement.sourceIndex;
  334.     theIFRAME.location.replace(filename);
  335.     tempSpan = theSpan
  336.     window.setTimeout("showPopup2(tempSpan,elemPos)", 800)
  337.     
  338.  
  339. }
  340.  
  341. function showPopup2(theSpan, elemPos){
  342. //var elemPos=0;
  343. //Get the position of the element which was clicked
  344. //elemPos = window.event.srcElement.sourceIndex;
  345.  
  346.     defSpan = document.all(theSpan);
  347.     if (defSpan && document.readyState == "complete" && theIFRAME.document.readyState == "complete"){
  348.             if (defSpan.style.display == "none"){
  349.             theIFRAME.document.all.tags("H1").item(0).outerHTML="";
  350.             
  351.             if(theIFRAME.document.all.tags("P").item("ExpandAllLine") != null) {theIFRAME.document.all.tags("P").item("ExpandAllLine").outerHTML="";}            
  352.             ///defSpan.innerHTML = theIFRAME.document.all.glosdef.innerHTML;
  353.             defSpan.innerHTML = theIFRAME.document.body.innerHTML;
  354.             defSpan.style.display = "";
  355.             defSpan.parentElement.style.display = "";
  356.  
  357.             document.all(elemPos+1).src="bluedrop.gif";
  358.             document.all(elemPos).src="bluedrop.gif";
  359.         }
  360.             else{
  361.             defSpan.style.display = "none";
  362.             defSpan.parentElement.style.display = "none";
  363.             document.all(elemPos+1).src="blueup.gif";
  364.             //if(oSource.tagName=="IMG"){open.src="blueup.gif";}
  365.             }
  366.     }
  367. }
  368.  
  369. //Swapping images
  370. function MM_swapImgRestore() { //v2.0
  371.   if (document.MM_swapImgData != null)
  372.     for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
  373.       document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
  374. }
  375.  
  376. function MM_swapImage() { //v2.0
  377.   var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  378.   for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
  379.     objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
  380.     if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
  381.         (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
  382.       objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
  383.     obj = eval(objStr);
  384.     if (obj != null) {
  385.       swapArray[j++] = obj;
  386.       swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
  387.       obj.src = MM_swapImage.arguments[i+2];
  388.   } }
  389.   document.MM_swapImgData = swapArray; //used for restore
  390. }